﻿using System;
using System.Data;
using System.Configuration;

using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.ComponentModel;
using System.Text;
using System.Collections.Generic;
using System.Text.RegularExpressions;

namespace TA.Turbo.Controls
{
	/// <summary>
	/// An event which can only be processed on the client.
	/// </summary>
	[TypeConverter(typeof(ExpandableObjectConverter))]
	public class SimpleClientEvent
	{
		#region PUBLIC
		#region INIT
		/// <summary>
		/// Ctor.
		/// </summary>
		public SimpleClientEvent()
		{
			this.Client = "";
		}
		#endregion
		#region PROPS
		/// <summary>
		/// Gets or sets the script that should be run on the client when the event is raised. 
		/// </summary>
		/// <remarks>
		/// Can be set to the name of a function or to a script block.
		/// </remarks>
		[NotifyParentProperty(true)]
		[DefaultValue("")]
		public string Client { get; set; }
		/// <summary>
		/// Gets the event handling script, obfuscated if necessary.
		/// </summary>
		[Browsable(false)]
		[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
		public string PreparedClient
		{
			get
			{
				if (this.Client == null)
					return null;
				return TPage.PrepareScript(this.Client);
			}
		}
		#endregion
		#region METHODS
		public void CopyFrom(SimpleClientEvent source)
		{
			this.Client = source.Client;
		}
		#endregion
		#endregion
	}
}